const path = require('path')
const resolve = dir => path.join(__dirname, dir)

// 通过配置文件实现解耦
const { baseUrl, host, port } = require('./project.config')

module.exports = {
  // Other configuration
  devServer: {
    // open: true,
    // host,
    // port,
    https: false,
    proxy: {
      // 跨域请求携带 proxy 头
      '/proxy': {
        target: 'https://www.imooc.com',
        ws: true,
        changOrigin: true,
        pathRewrite: {
          // 请求时取消 proxy 前缀
          '^/proxy': ''
        }
      }
    }
  }
}